'use strict';

angular.module('core')
    .factory('homeService', ['$q','$http',
        function($q,$http) {
            function getChartData(batchId) {
                var strs= new Array(); 
                if(batchId.indexOf(" ")>=0){
                    strs=batchId.split(" "); 
                }
                else if(batchId.indexOf(",")>=0){
                    strs=batchId.split(",");
                }
                else if(batchId.indexOf("，")>=0){
                    strs=batchId.split("，");
                }
                else{
                    strs=batchId
                }


                var deferred = $q.defer();
                
                $http({
                    method: 'POST',
                    url: 'api/core/findAllBarcodeMasterByLotNum',
                    data: {
                        Parameter: {
                            'MOLotNumber': strs
                        }
                    }
                }).success(function(data) {
                    
                    console.log(data);
                    deferred.resolve(data);

                }).error(function(err) {
                    console.log(err);
                    deferred.reject(err);
                });
                return deferred.promise;
            }
            return {
                getChartData: getChartData
            }
        }
    ]);